const nodemailer = require('nodemailer');

let transporter = nodemailer.createTransport({
    host: 'smtp.qq.com',
    secure: true,
    auth: {
        user: '1731098360@qq.com',
        pass: 'skrpkyivdazncfgi'
    }
});

module.exports = async function fn(email, code) {
    let status = null;
    await new Promise((resolve, reject) => {
        transporter.sendMail({
            from: '1731098360@qq.com',
            to: email,
            subject: '网站账户注册验证码',
            html: `
            <p>网站账户注册验证码：</p>
        <span style="font-size: 18px; color: red">` + code + `</span>`

        }, function(err, info) {
            if (err) {
                status = 0
                reject()
            } else {
                console.log("2");
                status = 1
                resolve()
            }
        });
    })
    console.log("1");
    return status
}